package com.sun.controller;

import com.sun.entity.EnhanceUserInfo;
import com.sun.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.UUID;

@EnableScheduling
@Slf4j
@RestController
public class TestController {

    @Autowired
    private UserInfoService userService;
    @RequestMapping("/test")
    public void test(){
        for (int i = 0; i < 4; i++) {
            EnhanceUserInfo userInfo = new EnhanceUserInfo();
            userInfo.setUserName(UUID.randomUUID().toString().substring(0,6)).setUserAddress(UUID.randomUUID().toString().substring(0,3))
                    .setUserEmail("234412421@qq.com").setUserStatus("0");
            userService.save(userInfo);
        }
    }

    @Scheduled(cron = "*/5 * * * * ?")
    public void test2() {
        log.debug("==================================================================================");
        log.error("<<<<<< error Start: 【{}】 >>>>>>", LocalDateTime.now());
        log.warn("<<<<<< warn Start: 【{}】 >>>>>>", LocalDateTime.now());
        log.info("<<<<<< info Start: 【{}】 >>>>>>", LocalDateTime.now());
        log.debug("<<<<<< debug Start: 【{}】 >>>>>>", LocalDateTime.now());
    }
}
